#pragma once

namespace RL
{
	namespace Engine
	{
		class Display;

		class Kernel
		{
		public:
			Kernel();
			~Kernel();

			bool setup(int width, int height, const std::string &title, bool fullscreen);
			void run();
			void stop();

			bool isConstructed() const { return _isConstructed; }
			bool isSetUp() const { return _isSetUp; }
			bool isRunning() const { return _isRunning; }

		private:
			bool _isConstructed;
			bool _isSetUp;
			bool _isRunning;

			clan::SetupCore __setupCore;
			clan::SetupDisplay __setupDisplay;
			clan::SetupD3D __setupD3D;
			clan::SetupGUI __setupGui;
			clan::SetupNetwork __setupNetwork;
			clan::SetupSound __setupSound;
			clan::ConsoleLogger __logger;

		private:
			void _setupClanLib();
			void _loadResources();
			void _setupDisplay(const std::string &title);
			void _addResourcesInDirectory(clan::ResourceManager &resources, clan::VirtualDirectory &vd, const std::string &directory);

			clan::ResourceManager *_resources;

		private:
			clan::DisplayWindow _window;
			clan::SceneCache _cache;
			clan::Scene _scene;
		};
	}
}
